import random
from django.shortcuts import render
from django.views.generic import View

from .pabaidu import paitu


# Create your views here.


class photo(View):
    """返回照片展示页"""

    def get(self, request):
        try:
            name = request.GET.get('type')
            if name != '':
                a = random.randint(6, 53)
                list_ = paitu(name)[a - 6:a + 6]
                return render(request, 'zhaopian.html', context={'list_jpg': list_})
            list_ = 1
            return render(request, 'zhaopian.html', context={'list_jpg': list_})

        except:
            list_ = 1
            return render(request, 'zhaopian.html', context={'list_jpg': list_})
